<?php

include_once APPLICATION_DIR . "/application/model/COMMENT.php";

class Comment extends DataObjects_COMMENT
{
	function getList($filter = array(), &$pager=false)
	{
		$comment = new Comment();
		if (isset($filter['name']) && $filter['name']) {
			$comment->whereAdd("COMMENT.TITLE LIKE '%".mysql_escape_string($filter['name'])."%' OR COMMENT.CONTENT LIKE '%".mysql_escape_string($filter['name'])."%'");
		}
        $comment->whereAdd("COMMENT.IS_DELETED = ".IS_NOT_DELETED);
        $comment->selectAdd();
        $comment->selectAdd("COMMENT.*");
		$comment->orderBy("COMMENT.TITLE");
		if ($pager == true) {
			$pager = new DBPager($comment, $filter, true);
		}
		
		$comment->find();

		return $comment;
	}
    
    function getCommentByIdVideo($id_video = 0)
	{
		$comment = new Comment();
        $comment->ID_VIDEO = $id_video;
		$comment->find();
		return $comment;
	}
}
